/*
* Author	: sgxiao
* Date		: Tue Dec 16 23:04:21 CST 2008
* version	: 0.2
* history	:
*	sgxiao	0.2	changing the caculating according to the right price
*	sgxiao	0.1 changing the caculating days from 0 ~ n-1  to 1 ~ n
*/

import java.io.*;
import java.util.*;

public class SimpleMovingAverage {
	public static void main(String[] args) throws IOException {
		if (args[0] == null || args[1] == null) {
			System.out.println("usage:\tSimpleMovingAverage filename \n\tnumber[1|2|5|10|50|150|200]\n");
			System.exit(1);
		}
		
		Vector<Double> vector = new Vector<Double>();
		Double total = 0.0;
		int span = Integer.valueOf(args[1]);
		Scanner scanner = new Scanner(new File(args[0]) );
		for(int i = 0; i < span - 1; i++) {
			//System.out.println(scanner.next() + "\t");
			scanner.next();
			System.out.println();
			
			scanner.nextDouble();
			
			//new added ... right price
			vector.add(scanner.nextDouble());
			total += vector.get(i);
		}
		
		int i = 0;
		while(scanner.hasNext()) {
			String date = scanner.next();
			//old one the close price
			scanner.nextDouble();
			
			//new added ... right price
			vector.add(scanner.nextDouble());

			//System.out.printf("%s\t%f\t%f\t%s\n", date, vector.get(span + i), total / span, vector.get(span + i) > total / span ? "buy" : "sell" );
			total += vector.get(span - 1 + i);
			System.out.printf("%f\n", total / span);
			total -= vector.get(i);

			
			
			i++;
		}
		
	}
}
